package main

import (
	"feng-che.com/server/driver-quiz/internal"
	"feng-che.com/server/driver-quiz/internal/ajaxSign"
	"feng-che.com/server/driver-quiz/internal/dep_db"
	"feng-che.com/server/driver-quiz/internal/institution"
	"feng-che.com/server/driver-quiz/internal/ossRW"
	"feng-che.com/server/driver-quiz/internal/services"
	"feng-che.com/server/driver-quiz/myApp"
	"gitee.com/dromara/carbon/v2"
)

func InitApp() {
	myApp.InitAppSetting()
	dep_db.ConnectDB()
	ossRW.AliyunOssClientInit()

	//ajaxSign.GenCommuKey()
	ajaxSign.ReadCommuPrivateKey()

	carbon.SetDefault(carbon.Default{
		Layout:       carbon.DateTimeLayout,
		Timezone:     carbon.PRC,
		Locale:       "zh-CN",
		WeekStartsAt: carbon.Monday,
		WeekendDays:  []carbon.Weekday{carbon.Saturday, carbon.Sunday},
	})

	go func() { //延迟执行

		internal.StartCronJob()
		go services.CacheAllAvailableService() //缓存所有服务
		go institution.CacheAllInstitution()   //缓存所有机构
		go institution.CacheAllVehicles()      //缓存所有机构

		//_id, _ := primitive.ObjectIDFromHex("67f78a28d24fa20e399fba43")
		//err := internal.MockPayDone(_id)
		//if err != nil {
		//	fmt.Print(err.Error())
		//}

	}()
}
